drupaldocfandomcom_ko-20200215-history
2단계: 데이터베이스 생성
Before running the installation script, you must create an empty database and database user (a user name assigned the rights to use the Drupal database). This page offers guidance for creating your Drupal database using a web browser-based control panel (such as "CPanel" or "Plesk"), or by using phpMyAdmin (another browser-based database utility), or by creating the database directly from the MySQL or PostgreSQL command prompt (for more advanced users). Create a database and user via a browser-based control panel Most web hosting accounts provide a Web-based control panel to help you administer your site. These tools include easy-to-use features for creating a new database, and for creating a "user" with rights to the database. To create a database using a browser-based control panel consult the documentation or ask your web host service provider. When you create the user for your database, you may see a page where you can specify the privileges that user will have for various operations on the database. In most web control panels' "database wizard", if you simply check "All" privileges for the user you create (and then uncheck "Grant" if it is listed as a privilege) your user will be set up correctly. Take note of the username, password, database name and hostname (eg. are you installing in http://example.com, or in http://drupal.example.com, or http://example.com/blog etc.) as you create the database. You will enter these items into fields in your browser when running the install script (see next page). Note that in many cases when creating databases and users via a web-based interface, the username you use to log into your control panel is added as a prefix to the database name and possibly to the database username as well. For example, if you log into your site's control panel as "webadmin" and create a database named "drupal7db" and a user for that database named "d7user", when running the Install script (see next page) the database and user may need to be typed in as "webadmin_drupal7db" and "webadmin_d7user". (This is because many hosting accounts are on shared servers, and on one server each database and user name must be unique across all accounts on the server.) If you have created your database and user via a web-based interface, you can skip the remainder of this page and continue with the install instructions on the next page. Create a database and user using phpMyAdmin This presumes you have root access to phpMyAdmin Log in to phpMyAdmin as the root user. Click Privileges and Add a new User. In the User name field, enter the username you wish to use. In the Host field, select Local which is more secure, unless you will be accessing the database with this user from another server. Enter or generate a password for the user. In the Database for User list, select Create database with same name and grant all privileges and click Go. You have now created a user that has all privileges only on the database with the same name. This is more secure than using a general username and password for all your sites on the same server, as it limits access to your databases if someone gets hold of your database logins. If you want to have a different name for database and user, just select the created database, then click the operations tab. You will find an option Rename database to. If you need more details about using PHPMyAdmin, check out the official wiki. Take note of the username, password, database name and hostname (eg. are you installing in http://example.com, or in http://drupal.example.com, or http://example.com/blog etc.) as you create the database. You will enter these items into fields in your browser when running the install script. Note that in many cases when creating databases and users using a web interface, the username you use to log in to your control panel is added as a prefix to the database name and possibly to the database username as well. For example, if you log into your site's control panel as "webadmin" and create a database named "drupal7db" and a user for that database named "d7user", when running the Install script (see next page) the database and user may need to be typed in as "webadmin_drupal7db" and "webadmin_d7user". (This is because many hosting accounts are on shared servers, and on one server each database and username must be unique across all accounts on the server.) If you have created your database and user via phpMyAdmin, you can skip the remainder of this page and continue with the install instructions on the next page. Create a database from the command line If you do not use a Web control panel or are experienced with and prefer to use MySQL or PostgreSQL commands, you can follow the information below. Additional information about privileges, and instructions to create a database using the command line are available in INSTALL.mysql.txt (for MySQL) or INSTALL.pgsql.txt (for PostgreSQL). Create a database using MySQL commands For information on installing and configuring MySQL see http://dev.mysql.com/tech-resources/articles/mysql_intro.html In the following examples, 'username' is an example MySQL user who will have the CREATE and GRANT privileges and 'databasename' is the name of the new database Use the appropriate names for your system. #Create a new database for your site. mysqladmin -u username -p create databasename MySQL prompts for the 'username' database password, and creates the initial database files. #Log in and set the access database rights: mysql -u username -p MySQL prompts for the 'username' database password. #At the MySQL prompt, set the permissions using the following command: GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, LOCK TABLES, CREATE TEMPORARY TABLES ON `databasename`.* TO 'username'@'localhost' IDENTIFIED BY 'password'; In this case: *'databasename' is the name of your database *'username@localhost' is the username of your MySQL account *'password' is the password required for that username You will need the ` around the database name if you have used a MySQL escape character in your schema name. Eg: drupal_test_account.* should be drupal\_test\_account.* for security (underscore is a wildcard). This requires the ` wrapper. `drupal\_test\_account`.* Note: unless your database user has all of the privileges listed above, you will not be able to run Drupal. #If successful, MySQL will reply with: Query OK, 0 rows affected #To activate the new permissions, enter the following command: FLUSH PRIVILEGES; The database should be created with UTF-8 (Unicode) encoding. #Now exit the MYSQL prompt by typing: exit The server will answer by saying Bye Create a database using PostgreSQL The database must be created with UTF-8 (Unicode) encoding. 1.Create a database user This step is only necessary if you don't already have a user setup (e.g. by your host) or you want to create new user for use with Drupal only. The following command creates a new user named 'username' (you should substitute this with the desired username), and prompts for a password for that user: createuser --pwprompt --encrypted --no-adduser --no-createdb username If everything works correctly, you'll see a CREATE USER notice. 2.Create the database This step is only necessary if you don't already have a database setup (e.g. by your host) or you want to create new database for use with Drupal only. The following command creates a new database named "databasename" (you should substitute this with the desired database name), which is owned by previously created "username": createdb --encoding=UNICODE --owner=username databasename If everything works correctly, you'll see a CREATE DATABASE notice.